package com.chaoxuan.uebt.adapter;

import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.daasuu.bl.BubbleLayout;
import com.chaoxuan.uebt.R;
import com.chaoxuan.uebt.model.News;
import com.chaoxuan.uebt.model.Timeline;

/**
 * Created by Administrator on 2019/5/24.
 */
public class TimelineAdapter extends BaseQuickAdapter<Timeline,BaseViewHolder>{
    int blue,grey;
    public TimelineAdapter() {
        super(R.layout.fragment_welcome_item);
        blue=Color.parseColor("#485173");
        grey=Color.parseColor("#EAECE6");
    }

    @Override
    protected void convert(BaseViewHolder helper, Timeline item) {
        if(item.isFirst()){
            helper.getView(R.id.view_center1).setVisibility(View.VISIBLE);
            helper.getView(R.id.view_center2).setVisibility(View.GONE);
        }else{
            helper.getView(R.id.view_center1).setVisibility(View.GONE);
            helper.getView(R.id.view_center2).setVisibility(View.VISIBLE);
        }

        if (item.isLeft()){
            helper.getView(R.id.view_left).setVisibility(View.VISIBLE);
            helper.getView(R.id.view_right).setVisibility(View.GONE);
            BubbleLayout bubbleLayout= helper.getView(R.id.bubble_left);
            TextView tv=helper.getView(R.id.tv_left_text);
            if(item.isCur()) {
                bubbleLayout.setBubbleColor(blue);
                tv.setTextColor(Color.WHITE);
            }else{
                bubbleLayout.setBubbleColor(grey);
                tv.setTextColor(blue);
            }
            tv.setText(item.getText());
            helper.setText(R.id.tv_left_time,item.getTime());
        }else{
            helper.getView(R.id.view_left).setVisibility(View.GONE);
            helper.getView(R.id.view_right).setVisibility(View.VISIBLE);
            BubbleLayout bubbleLayout= helper.getView(R.id.bubble_right);
            TextView tv=helper.getView(R.id.tv_right_text);
            if(item.isCur()) {
                bubbleLayout.setBubbleColor(blue);
                tv.setTextColor(Color.WHITE);
            }else{
                bubbleLayout.setBubbleColor(grey);
                tv.setTextColor(blue);
            }
            tv.setText(item.getText());
            helper.setText(R.id.tv_right_time,item.getTime());
        }
    }
}
